package chapter11;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * @author Keximo
 * @version v 1.0
 * @date 2020/8/3
 */
public class PrestoAPIApp {
    public static void main(String[] args) throws Exception{
        Class.forName("com.facebook.presto.jdbc.PrestoDriver");

        Connection conn = DriverManager.getConnection("jdbc:presto://hadoop000:8080/hive/myhive", "root", "");
        Statement statement = conn.createStatement();
//        ResultSet resultSet = statement.executeQuery("select * from score");
//        while (resultSet.next()){
//            System.out.println(resultSet.getString("s_id")+" "+resultSet.getString("c_id")+" "+resultSet.getString("score"));
//        }

        ResultSet resultSet = statement.executeQuery("select * from hive.myhive.score s join mysql.myhive.student st on s.s_id=st.s_id");
        while (resultSet.next()){
           System.out.println(resultSet.getString("s_id")+" "+resultSet.getString("s_name")+" "+resultSet.getString("c_id")+" "+resultSet.getString("score"));
       }
        resultSet.close();
        conn.close();
    }
}
